import { deletePlayWith } from "@/apis/playWith";
import { statement } from "@/apis/settle";
import DefaultTable from "@/components/DefaultTable";
import { getBreadcRumb, push } from "@/utils/util";
import { Space, Button, Popconfirm, message } from "antd";
import { ColumnsType } from 'antd/es/table'
import { useEffect, useRef } from "react";

function PlayWithManage() {
    getBreadcRumb([{ name: "结算列表" }])
    const TableRef = useRef<TableRefParams>(null)
    const columns: ColumnsType<BaselistItem> = [
        {
            title: "序号",
            dataIndex: "itemSn",
            render: (_text, record, index) => (((record.pageNum || 0) - 1) * (record.pageSize || 0) + index + 1)
        },
        {
            title: "陪玩名称",
            dataIndex: "playWithName",
        },
        {
            title: "待结算金额",
            dataIndex: "settleAmount",
        },
        {
            title: "结算状态",
            dataIndex: "settleStatus",
            render: (text: string) => text == "1" ? "已结算" : "待结算"
        },
        {
            title: "操作",
            dataIndex: "index",
            render: (_index: any, data: any) => {
                return (
                    <Space>
                        <Popconfirm title="确定结算嘛?" onConfirm={() => onSettleBtn(data.playWithId)}>
                            <a >结算</a>
                        </Popconfirm>
                    </Space>
                );
            },
        },
    ]
    useEffect(() => {
        TableRef.current?.getList()
    }, [])
    //结算
    async function onSettleBtn(id: string) {
        await statement({ playWithId: id })
        message.success("结算成功")
        TableRef.current?.getList()
    }
    return (
        <div>
            <div className='tableWrap'>

                <DefaultTable columns={columns} ref={TableRef} api={'/settle/list'} />
            </div>
        </div>
    )
}
export default PlayWithManage;
